package com.xmkj.bearbiz.my.adapter;

import android.content.Context;
import android.graphics.Color;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
import android.view.View;
import android.widget.TextView;

import com.common.Entity.ZhongJiangEntity;
import com.common.widget.recyclerview.refresh.adapter.CommonAdapter;
import com.common.widget.recyclerview.refresh.adapter.ViewHolder;
import com.xmkj.bearbiz.R;

import java.util.List;

public class ZhongJiangRecordAdapter extends CommonAdapter<ZhongJiangEntity.ListsBean> {
    public ZhongJiangRecordAdapter(Context context, List<ZhongJiangEntity.ListsBean> data) {
        super(context, data);
    }

    @Override
    protected void convert(ViewHolder holder, ZhongJiangEntity.ListsBean item, int position) {
        holder.setImageStr(R.id.iv_img, item.goods_thumb);
        holder.setText(R.id.tv_name, item.goods_name);
        holder.setText(R.id.tv_name, "期号：" + item.fvid);
        holder.setText(R.id.tv_time, "揭晓时间：" + item.opentime);
        TextView tvAll = holder.getView(R.id.tv_renshu);
        TextView tvThisTime = holder.getView(R.id.tv_this_renshu);
        TextView tvLuck = holder.getView(R.id.tv_lucky_num);
        if (item.open_type == 2) {
            tvAll.setVisibility(View.VISIBLE);
            tvThisTime.setVisibility(View.VISIBLE);
            tvLuck.setVisibility(View.VISIBLE);

            tvAll.setText("总需：" + item.total_num);
            tvThisTime.setText("本期参与：" + item.partake_num);
            SpannableString spannableString = new SpannableString("幸运号码：" + item.lucky_code);
            spannableString.setSpan(new ForegroundColorSpan(Color.parseColor("#FF0E41")), 5, spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            tvLuck.setText(spannableString);

        } else {

            tvAll.setVisibility(View.GONE);
            tvThisTime.setVisibility(View.GONE);
            tvLuck.setVisibility(View.VISIBLE);
            SpannableString spannableString = new SpannableString("竞拍积分：" + item.score);
            spannableString.setSpan(new ForegroundColorSpan(Color.parseColor("#FF0E41")), 5, spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            tvLuck.setText(spannableString);
        }


    }

    @Override
    protected int getItemViewLayoutId(int position, ZhongJiangEntity.ListsBean item) {
        return R.layout.item_zhongjiang_records;
    }
}
